import request from "@/utils/request";

// 楼幢列表
export function buildingList(data) {
  return request({
    url: "/virlib-admin/building/query",
    method: "post",
    data,
  });
}

// 楼层列表
export function floorList(data) {
  return request({
    url: "/virlib-admin/map/query",
    method: "post",
    data,
  });
}

// 删除楼幢
export function deleteBuilding(buildingId) {
  return request({
    url: `/virlib-admin/building/${buildingId}`,
    method: "delete",
  });
}

// 新建楼幢
export function addBuilding(data) {
  return request({
    url: "/virlib-admin/building",
    method: "put",
    data,
  });
}

// 修改楼幢
export function editBuilding(data) {
  return request({
    url: "/virlib-admin/building",
    method: "post",
    data,
  });
}

// 新建楼层
export function addFloor(data) {
  return request({
    url: "/virlib-admin/map",
    method: "put",
    data,
  });
}

// 修改楼层
export function editFloor(data) {
  return request({
    url: "/virlib-admin/map",
    method: "post",
    data,
  });
}

// 删除楼层
export function deleteFloor(mapId) {
  return request({
    url: `/virlib-admin/map/${mapId}`,
    method: "delete",
  });
}

// 修改或新增楼层的点位
export function editOrAddPoint(mapId, data, falge) {
  return request({
    url: `/virlib-admin/positions/${mapId}?clean=${falge}`,
    method: "put",
    data,
  });
}

// 查询楼层的点位
export function getPoint(mapId) {
  return request({
    url: `/virlib-admin/positions/${mapId}`,
    method: "get",
  });
}

// 同步数据
export function synchronizeData() {
  return request({
    url: "/compiled/recompile",
    method: "get",
  });
}

// 楼幢集合
export function getbuildingArr() {
  return request({
    url: "/virlib-admin/building/list",
    method: "get",
  });
}

// 楼层集合（地图集合）
export function getfloorArr(buildingId) {
  let url;
  if (buildingId || buildingId === 0) {
    url = `/virlib-admin/map/list/${buildingId}`;
  } else {
    url = `/virlib-admin/map/list`;
  }
  return request({
    url: url,
    method: "get",
  });
}
